<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/pages/common/taglibs.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>广东工业大学招生办后台管理</title>
<link rel="stylesheet" href="${ctx }/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="${ctx }/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="${ctx }/kindeditor/lang/zh_CN.js"></script>

<script>
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]', {
			cssPath : '${ctx}/kindeditor/plugins/code/prettify.css',
				uploadJson :  '${ctx}/kindeditor/jsp/upload_json.jsp',  
				fileManagerJson : '${ctx}/kindeditor/jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['article'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['article'].submit();
					});
				}
			});
			prettyPrint();
		});
	function check(){
		//提交前设置latestAnnouncement，latestReading的值为是或否
		var announcementCheckbox = document.getElementById("announcement");
		var readingCheckbox = document.getElementById("reading");
		var announcementInput = document.getElementById("latestAnnouncement");
		var readingInput = document.getElementById("latestReading");
		if(announcementCheckbox.checked){
			announcementInput.value="1";
		}else{
			announcementInput.value="0";
		}
		if(readingCheckbox.checked){
			readingInput.value="1";
		}else{
			readingInput.value="0";
		}
	
		var title = document.getElementById("title");
		if(title.value==""){
			alert("请输入标题！");
			return false;
		}
		if(editor.isEmpty()){
			alert("请输入内容！");
			return false;
		}
		
		else true;
		
	}
</script>
  </head>
  
  <body>
	<div class="article">
		<form action="admission-policy-admin!save.action" method="post" name="article" onsubmit="return check()" >
		<input type="hidden" name="entity.latestReading" id="latestReading"/>
		<input type="hidden" name="entity.latestAnnouncement" id="latestAnnouncement"/>
		<s:if test="id!=null"><input type="hidden" name="id" value="${id}"/></s:if>
			<table style="width:100%">
				<tr>
					<td align="right">标题：</td>
					<td><input type="text"  id="title" name="entity.title" style="width:100%" value="${title }"/></td>
				</tr>
				<tr>
					<td></td>
					<td>
						<input type="checkbox" id="announcement"  <s:if test="latestAnnouncement==1"> checked="checked"</s:if> />发布到最新公告
						<input type="checkbox" id="reading" <s:if test="latestReading==1"> checked="checked"</s:if> />发布到最新导读
					</td>
				</tr>
				<tr>
					<td align="right">内容：</td>
					<td>
						<textarea name="content" style="width:100%;height:400px;visibility:hidden;">${content }</textarea>
					</td>
				</tr>
				<tr>
					<td> </td>
					<td align="right">
						<input type="submit" class="button" value="提交" style="width:80px;" /> 
					</td>
				</tr>
			</table>
				
				

		</form>
	</div>
	</body>
  </html>